<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="业务活动" prop="activityName">
            <el-input size="small" v-model="queryParams.activityName" placeholder="请输入业务活动"/>
          </el-form-item>
        </el-col>
        <el-col :span="18" style="text-align: right">
          <el-button type="primary" size="small" @click="handleQuery">查询</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-row :gutter="30">
      <el-table :data="riskList" border ref="multipleTable"
                @selection-change="handleSelectionChange" :row-key="getRowKeys"
      >
        <el-table-column type="selection" :reserve-selection="true"></el-table-column>
        <el-table-column label="序号" width="50px" type="index"/>
        <el-table-column label="业务活动" align="center" key="activityName" prop="activityName" width="100px"/>
        <el-table-column label="业务事项" align="center" key="event" prop="event" :show-overflow-tooltip="true"
                         min-width="100px"
        >
          <template slot-scope="{row}">
            <span>{{ row.event }}</span>
          </template>
        </el-table-column>
        <el-table-column label="风险描述" align="center" key="description" prop="description"
                         :show-overflow-tooltip="true" min-width="100px"
        >
          <template slot-scope="{row}">
            <span>{{ row.description }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="合规义务">
          <el-table-column
            prop="regulations"
            align="center"
            label="涉及到的法律法规及发条"
            :show-overflow-tooltip="true"
            min-width="100px"
          >
            <template slot-scope="{row}">
              <span>{{ row.regulations }}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="法规政策要求">
            <el-table-column
              prop="prohibitedMatter"
              label="禁止事项"
              :show-overflow-tooltip="true"
              min-width="100px"
            >
              <template slot-scope="{row}">
                <span>{{ row.prohibitedMatter }}</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="completionItem"
              label="需要完成事项"
              :show-overflow-tooltip="true"
              min-width="100px"
            >
              <template slot-scope="{row}">
                <span>{{ row.completionItem }}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column
            prop="consequencePunishment"
            align="center"
            label="违规引发的触发后果"
            :show-overflow-tooltip="true"
            min-width="100px"
          >
            <template slot-scope="{row}">
              <span>{{ row.consequencePunishment }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column align="center" label="风险管理措施">
          <el-table-column
            prop="suggestion"
            label="合规风险防控建议"
            :show-overflow-tooltip="true"
            min-width="100px"
          >
            <template slot-scope="{row}">
              <span>{{ row.consequencePunishment }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="controlSystem"
            label="公司内部管控制度"
            :show-overflow-tooltip="true"
            min-width="100px"
          >
            <template slot-scope="{row}">
              <span>{{ row.controlSystem }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="supervisor"
            align="center"
            label="具体管理程序"
            :show-overflow-tooltip="true"
            min-width="100px"
          >
            <template slot-scope="{row}">
              <span>{{ row.supervisor }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="措施落实责任部门（逗号前为牵头部门）"
            width="160"
          >
            <template slot-scope="scope">
              {{ scope.row.leadDeptName + ',' + scope.row.implementDeptName }}
            </template>
          </el-table-column>
          <el-table-column
            prop="riskLevel"
            align="center"
            label="风险评估等级"
            width="160"
          >
          </el-table-column>
        </el-table-column>
<!--        <el-table-column label="已绑定流程信息" align="center" key="deptType" prop="deptType"/>-->
      </el-table>
      <div class="text-center mar-top-20">
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </el-row>
  </div>
</template>

<script>
import { listRisk } from '@/api/lc/risk'

export default {
  name: 'complianceTreeTable',
  data() {
    return {
      // 表格数据
      riskList: [],
      total: 0,
      totalPage: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        activityId: '',
        description: ''
      },
      //记录每行的key值
      getRowKeys(row) {
        return row.riskId
      },
      multipleSelection: [], // 表格选中
      select_number: '', //表格select选中的条数
      select_Id: [] //表格select复选框选中的id
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    init() {
      this.riskList = []
      this.total = 0
      this.totalPage = 0,
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          activityId: '',
          description: ''
        }
      this.multipleSelection = []
      this.select_number = ''
      this.select_Id = []
      this.getList()
      this.$refs.multipleTable.clearSelection();
    },
    handleQuery(){
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 查询合规风险提示库列表 */
    getList() {
      this.loading = true
      listRisk(this.addDateRange(this.queryParams)).then(response => {
        this.riskList = response.rows
        this.total = response.total
      })
    },
    handleSelectionChange(rows) {
      this.multipleSelection = rows
      this.select_number = this.multipleSelection.length
      this.select_Id = []
      if (rows) {
        rows.forEach((row) => {
          if (row) {
            this.select_Id.push(row.id)
          }
        })
      }
      this.$emit('checkData', this.multipleSelection)
    }
  }
}
</script>

<style scoped>

</style>
